﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using eschoolBO;

namespace ESCHOOL.students
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        student stud = new student();
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Visible = false;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            DataTable dt = stud.GetRecords(Convert.ToInt64(Session["userid"]), "", -99, -99, "", "", "", "", "", "", -99, -99, "", -99, "", TextBox1.Text,"","", false, " and ");
            if (dt.Rows.Count > 0)
            {
                stud.student_id = Convert.ToInt64(dt.Rows[0]["student_id"].ToString());
                stud.enrollment_no = dt.Rows[0]["enrollment_no"].ToString();
                stud.roll_no = Convert.ToInt64(dt.Rows[0]["roll_no"].ToString());
                stud.year_of_studing = dt.Rows[0]["year_of_studing"].ToString();
                stud.student_name = dt.Rows[0]["student_name"].ToString();
                stud.date_of_birth = dt.Rows[0]["date_of_birth"].ToString();
                stud.gender = dt.Rows[0]["gender"].ToString();
                stud.photo = dt.Rows[0]["photo"].ToString();
                stud.permanent_address = dt.Rows[0]["permanent_address"].ToString();
                stud.residence_pno = Convert.ToInt64(dt.Rows[0]["residence_pno"].ToString());
                stud.mobile_no = Convert.ToInt64(dt.Rows[0]["mobile_no"].ToString());
                stud.student_emailid = dt.Rows[0]["student_emailid"].ToString();
                stud.user_type_id = Convert.ToInt64(dt.Rows[0]["user_type_id"].ToString());
                stud.class_id = Convert.ToInt64(dt.Rows[0]["class_id"].ToString());
                stud.username = dt.Rows[0]["username"].ToString();
                stud.password = TextBox2.Text;
                stud.isdeleted = false;
                stud.SaveRecords();
                Label1.Visible = true;
                TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = "";
                Panel1.Visible = false;
                Label1.Text = "Your password has been changed.";
            }
            else
            {
                Label1.Visible = true;
                Label1.Text = "Try again.";
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/students/Changepassword.aspx");
        }
    }
}
